﻿Imports System
Imports System.Windows
Imports System.Windows.Forms
Imports System.Windows.Forms.Control

Namespace XPControl
    Public NotInheritable Class ComboBox
        Private Shared Ctrl As System.Windows.Forms.Control

        Public Shared GotForeColor As System.Drawing.Color = System.Drawing.Color.Black
        Public Shared GotBackColor As System.Drawing.Color = System.Drawing.Color.GreenYellow

        Public Shared LostForeColor As System.Drawing.Color = System.Drawing.SystemColors.ControlText
        Public Shared LostBackColor As System.Drawing.Color = System.Drawing.Color.LightCyan

        Public Shared Sub ComboBox_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Dim ComboBox As System.Windows.Forms.ComboBox = CType(sender, System.Windows.Forms.ComboBox)
            ComboBox.ForeColor = GotForeColor
            ComboBox.BackColor = GotBackColor
        End Sub

        Public Shared Sub ComboBox_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Dim ComboBox As System.Windows.Forms.ComboBox = CType(sender, System.Windows.Forms.ComboBox)
            ComboBox.ForeColor = LostForeColor
            ComboBox.BackColor = LostBackColor
        End Sub

        Public Shared Sub ComboBox_SelectedItem(ByVal Sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
            Dim ComboBox As System.Windows.Forms.ComboBox = CType(Sender, System.Windows.Forms.ComboBox)
            ComboBox.SelectedItem = e.KeyChar
        End Sub

        Public Shared Sub ComboBox_Keypress(ByVal Sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
            e.Handled = True
        End Sub

        Public Shared Sub EnableComboboxInGB(ByVal gb As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In gb.Controls
                If TypeOf Ctrl Is System.Windows.Forms.ComboBox Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisableComboboxInGB(ByVal gb As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In gb.Controls
                If TypeOf Ctrl Is System.Windows.Forms.ComboBox Then Ctrl.Enabled = False
            Next
        End Sub

        Public Shared Sub EnableComboboxInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is System.Windows.Forms.ComboBox Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisableComboboxInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is System.Windows.Forms.ComboBox Then Ctrl.Enabled = False
            Next
        End Sub

    End Class
End Namespace
